import { Draw } from "ol/interaction";
import { createBox } from "ol/interaction/Draw.js";
import { Circle as CircleStyle, Fill, Stroke, Style } from "ol/style";

let draw;
export const drawType = (source: any, type: any) => {
  let geometryFunction;

  draw = new Draw({
    source: source,
    type: type === "Rectangle" ? "Circle" : type,
    geometryFunction: (type === "Rectangle" ? createBox() : "") as any,
    style: new Style({
      fill: new Fill({
        color: "rgba(195, 59, 83, 0.2)",
      }),
      stroke: new Stroke({
        color: "#bf3b53",
        lineDash: [10, 10],
        width: 2,
      }),
      image: new CircleStyle({
        radius: 5,
        fill: new Fill({
          color: "rgba(195, 59, 83, 0.2)",
        }),
        stroke: new Stroke({
          color: "rgba(195, 59, 83, 1)",
          width: 2,
        }),
      }),
    }),
  });
  return draw;
};
